/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logiclander.adhocracy.jira.config;

import com.logiclander.adhocracy.httpclient.SSLV3ProtocolSocketFactory;
import com.atlassian.jira.rest.client.AuthenticationHandler;
import com.atlassian.jira.rest.client.JiraRestClient;
import com.atlassian.jira.rest.client.JiraRestClientFactory;
import com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler;
import com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClient;
import java.net.URI;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;

/**
 *
 * @author tim
 */
public class JerseyJiraRestClientFactorySSLv3 implements JiraRestClientFactory {

    @Override
    public JiraRestClient create(URI serverUri, AuthenticationHandler authenticationHandler) {
        return new JerseyJiraRestClient(serverUri, authenticationHandler);
    }

    @Override
    public JiraRestClient createWithBasicHttpAuthentication(URI serverUri, String username, String password) {
        Protocol sslv3 = new Protocol("https", (ProtocolSocketFactory) new SSLV3ProtocolSocketFactory(), 443);
        Protocol.registerProtocol("https", sslv3);
        return create(serverUri, new BasicHttpAuthenticationHandler(username, password));
    }
}
